<template>
  <!-- <el-select v-model="value" placeholder="请选择" @change="changeValue($event)" clearable >
    <el-option
      v-for="item in partys"
      :key="item.code"
      :label="item.name"
      :value="item.code"
    />
  </el-select> -->
  <!-- <el-autocomplete
    class="inline-input"
    v-model="value"
    :fetch-suggestions="querySearch"
    placeholder="请输入内容"
    @select="changeValue($event)"
    style="width:100%"
    clearable
  >
  </el-autocomplete>             -->
  <el-select v-model="value" filterable placeholder="请选择" @change="changeValue" clearable style="width:100%">
    <el-option
      v-for="item in partys"
      :key="item.code"
      :label="item.name"
      :value="item"
    />
  </el-select>
</template>
<script>
import request from '@/utils/request'
export default {
  data() {
    return {
      value: '',
      partys: [],
      callbackMethod: '',
      partyName: ''
    }
  },
  created() {
    this.findShipmentPartys()
  },
  methods: {
    findShipmentPartys() {
      request({
        url: '/wms/customer/chooseData',
        method: 'get',
      }).then(response => {
        this.partys = response.data
      })
    },

    changeValue(value) {
      this.value = value.name
      let relation = {}
      relation.code =  value.code
      relation.contacts = value.contacts,
      relation.receiverMobile = value.phone,
      relation.receiveAddress = value.address
      relation.receiverProvince = value.province
      relation.receiverCity = value.city
      relation.receiverDistrict = value.county
      this.$emit("getCustomerCode", value.name, value.code)
      this.$emit("relation", relation)
    },
    setSelectValue(value) {
      if(value!=''){
        this.partys.forEach(i =>{
          if(i.code == value){
            this.value = i.name
          }
          if(i.name == value){
            this.value = value
          }
        })
      }else{
        this.value = value
      } 
    },
  }
}
</script>

<style scoped>
.el-select-dropdown__item.selected{
  color: #606266;
  font-weight: 400;
}
</style>
